﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SessionExample
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                Session["texts"] = new List<string>();
            }
        }

        protected void addToSession_Click(object sender, EventArgs e)
        {
            if (this.inputTxt.Text != null)
            {
                ((List<string>)Session["texts"]).Add(this.inputTxt.Text);
            }
            this.inputTxt.Text = "";
            foreach (var text in ((List<string>)Session["texts"]))
            {
                Literal l = new Literal();
                l.Text = text + "<br/>";
                this.myPH.Controls.Add(l);
            }
        }
    }
}